﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.Record;
using TyMES.Model;

namespace TyMES.ViewModel.Record.PassStationRecordVMs
{
    public partial class PassStationRecordListVM : BasePagedListVM<PassStationRecord_View, PassStationRecordSearcher>
    {
        
        protected override IEnumerable<IGridColumn<PassStationRecord_View>> InitGridHeader()
        {
            return new List<GridColumn<PassStationRecord_View>>{
                
                this.MakeGridHeader(x => x.PassStationRecord_lineCode).SetTitle(@Localizer["Page.产线编码"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_materialCode).SetTitle(@Localizer["Page.物料编码"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_materialName).SetTitle(@Localizer["Page.物料名称"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_materialVersion).SetTitle(@Localizer["Page.物料版本"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_operationCode).SetTitle(@Localizer["Page.工序编码"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_orderCode).SetTitle(@Localizer["Page.工单编码"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_passBeginTime).SetTitle(@Localizer["Page.进站时间"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_passEndTime).SetTitle(@Localizer["Page.出站时间"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_passStatus).SetTitle(@Localizer["Page.过站状态"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_scheduleCode).SetTitle(@Localizer["Page.排程编号"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_snNumber).SetTitle(@Localizer["Page.SN"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_stationCode).SetTitle(@Localizer["Page.工位编号"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_shipCode).SetTitle(@Localizer["Page.出货条码"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_machineCode).SetTitle(@Localizer["Page.设备号"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_uploadflag).SetTitle(@Localizer["Page.上传工厂mes标志"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_userId).SetTitle(@Localizer["Page.userId"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_userName).SetTitle(@Localizer["Page.userName"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_isProduct).SetTitle(@Localizer["Page.出货标识"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_reqType).SetTitle(@Localizer["Page.进出站标识"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.PassStationRecord_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<PassStationRecord_View> GetSearchQuery()
        {
            var query = DC.Set<PassStationRecord>()
                
                .CheckContain(Searcher.LineCode, x=>x.LineCode)
                .CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
                .CheckContain(Searcher.MaterialName, x=>x.MaterialName)
                .CheckContain(Searcher.MaterialVersion, x=>x.MaterialVersion)
                .CheckContain(Searcher.OperationCode, x=>x.OperationCode)
                .CheckContain(Searcher.OrderCode, x=>x.OrderCode)
                .CheckContain(Searcher.PassBeginTime, x=>x.PassBeginTime)
                .CheckContain(Searcher.PassEndTime, x=>x.PassEndTime)
                .CheckContain(Searcher.PassStatus, x=>x.PassStatus)
                .CheckContain(Searcher.ScheduleCode, x=>x.ScheduleCode)
                .CheckContain(Searcher.SnNumber, x=>x.SnNumber)
                .CheckContain(Searcher.StationCode, x=>x.StationCode)
                .CheckContain(Searcher.ShipCode, x=>x.ShipCode)
                .CheckContain(Searcher.MachineCode, x=>x.MachineCode)
                .CheckEqual(Searcher.Uploadflag, x=>x.Uploadflag)
                .CheckContain(Searcher.UserId, x=>x.UserId)
                .CheckContain(Searcher.UserName, x=>x.UserName)
                .CheckContain(Searcher.IsProduct, x=>x.IsProduct)
                .CheckContain(Searcher.ReqType, x=>x.ReqType)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new PassStationRecord_View
                {
				    ID = x.ID,
                    
                    PassStationRecord_lineCode = x.LineCode,
                    PassStationRecord_materialCode = x.MaterialCode,
                    PassStationRecord_materialName = x.MaterialName,
                    PassStationRecord_materialVersion = x.MaterialVersion,
                    PassStationRecord_operationCode = x.OperationCode,
                    PassStationRecord_orderCode = x.OrderCode,
                    PassStationRecord_passBeginTime = x.PassBeginTime,
                    PassStationRecord_passEndTime = x.PassEndTime,
                    PassStationRecord_passStatus = x.PassStatus,
                    PassStationRecord_scheduleCode = x.ScheduleCode,
                    PassStationRecord_snNumber = x.SnNumber,
                    PassStationRecord_stationCode = x.StationCode,
                    PassStationRecord_shipCode = x.ShipCode,
                    PassStationRecord_machineCode = x.MachineCode,
                    PassStationRecord_uploadflag = x.Uploadflag,
                    PassStationRecord_userId = x.UserId,
                    PassStationRecord_userName = x.UserName,
                    PassStationRecord_isProduct = x.IsProduct,
                    PassStationRecord_reqType = x.ReqType,
                    PassStationRecord_CreateTime = x.CreateTime,
                    PassStationRecord_UpdateTime = x.UpdateTime,
                    PassStationRecord_CreateBy = x.CreateBy,
                    PassStationRecord_UpdateBy = x.UpdateBy,
                })
                .OrderByDescending(x => x.ID);
            return query;
        }

        
    }
    public class PassStationRecord_View: PassStationRecord
    {
        
        public string PassStationRecord_lineCode { get; set; }
        public string PassStationRecord_materialCode { get; set; }
        public string PassStationRecord_materialName { get; set; }
        public string PassStationRecord_materialVersion { get; set; }
        public string PassStationRecord_operationCode { get; set; }
        public string PassStationRecord_orderCode { get; set; }
        public string PassStationRecord_passBeginTime { get; set; }
        public string PassStationRecord_passEndTime { get; set; }
        public string PassStationRecord_passStatus { get; set; }
        public string PassStationRecord_scheduleCode { get; set; }
        public string PassStationRecord_snNumber { get; set; }
        public string PassStationRecord_stationCode { get; set; }
        public string PassStationRecord_shipCode { get; set; }
        public string PassStationRecord_machineCode { get; set; }
        public bool? PassStationRecord_uploadflag { get; set; }
        public string PassStationRecord_userId { get; set; }
        public string PassStationRecord_userName { get; set; }
        public string PassStationRecord_isProduct { get; set; }
        public string PassStationRecord_reqType { get; set; }
        public DateTime? PassStationRecord_CreateTime { get; set; }
        public DateTime? PassStationRecord_UpdateTime { get; set; }
        public string PassStationRecord_CreateBy { get; set; }
        public string PassStationRecord_UpdateBy { get; set; }

    }

}